#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
using namespace std;




int main() 
{
	int m, n;
	cin >> m >> n;
	vector<int> days(m + 1, 0);
	for (int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		for (int j = l; j <= r; j++) 
		{
			days[j] = 1;
		}
	}
	int flag = 0;
	for (int i = 1; i <= m; i++) 
	{
		if (days[i] == 0)
		{
			flag++;
		}
	}
	cout << flag;
	return 0;
}












